function t(t) {
    if (Array.isArray(t)) {
        for (var a = 0, e = Array(t.length); a < t.length; a++) e[a] = t[a];
        return e;
    }
    return Array.from(t);
}

Page({
    data: {
        more_list: !1,
        page: 2,
        share: 0,
        mch: 0,
        page_loading: !1,
        keyword: "",
        toSearch: !1,
        _num: "1",
        list: [],
        status: "0",
        cash_status: null,
        content: "",
        cash_price: 0,
        beSearch: !1,
        is_pass: !1,
        is_refuse: !1,
        is_cash: !1,
        is_decline: !1,
        id: null,
        actions: [ {
            name: "取消",
            color: "#666666"
        }, {
            name: "确认",
            color: "#446dfd",
            loading: !1
        } ]
    },
    beSearch: function() {
        var t = !this.data.toSearch;
        this.data.keyword.length > 0 && (t = this.data.toSearch), this.setData({
            toSearch: t
        });
    },
    keywordInput: function(t) {
        this.setData({
            keyword: t.detail.value
        });
    },
    search: function() {
        this.getList(1);
    },
    tab: function(t) {
        var a = t.currentTarget.dataset.num;
        this.setData({
            _num: a,
            status: "0",
            list: []
        }), this.getList(1);
    },
    tabStatus: function(t) {
        var a = t.currentTarget.dataset.status;
        this.setData({
            status: a,
            list: []
        }), this.getList(1);
    },
    cash: function(a) {
        var e = this, i = a.detail.index;
        if (0 === i) this.setData({
            is_cash: !1,
            is_decline: !1,
            is_pass: !1,
            is_refuse: !1,
            content: ""
        }); else if (1 === i) {
            [].concat(t(this.data.actions))[1].loading = !0, getApp().core.showLoading({
                content: "加载中",
            });
            var s = void 0;
            this.data.cash_status = this.data.cash_status == 0 ? 2 : this.data.cash_status;
            1 == this.data._num ? s = {
                id: this.data.id,
                type: this.data._num,
                content: this.data.content,
                status: this.data.cash_status
            } : 2 == this.data._num && (s = {
                id: this.data.id,
                type: this.data._num,
                content: this.data.content,
                status: this.data.cash_status
            }), getApp().request({
                url: getApp().api.admin.cash.submit,
                data: s,
                method: "get",
                success: function(t) {
                  getApp().core.hideLoading(), 0 == t.code ? (e.setData({
                    is_cash: !1,
                    is_decline: !1,
                    is_pass: !1,
                    is_refuse: !1,
                    content: ""
                  }), e.getList(1)) : getApp().core.showToast({
                    title: t.msg,
                    icon: 'none'
                  });
                },
                fail: function(t) {
                  getApp().core.showToast({
                    content: t.msg,
                    icon: 'none'
                  });
                }
            });
        }
    },
    pass: function(a) {
        var e = this, i = a.detail.index;
        0 === i ? this.setData({
            is_pass: !1,
            is_refuse: !1,
            content: ""
        }) : 1 === i && ([].concat(t(this.data.actions))[1].loading = !0, getApp().iView.$Toast({
            content: "加载中",
            type: "loading",
            duration: 0
        }), getApp().request({
            url: getApp().apiUrl.app_admin.verify,
            data: {
                id: this.data.id,
                status: this.data.cash_status,
                type: this.data._num,
                content: this.data.content
            },
            method: "post"
        }).then(function(t) {
            getApp().iView.$Toast.hide(), 0 == t.data.code ? (e.setData({
                is_pass: !1,
                is_refuse: !1,
                content: ""
            }), e.getList(1)) : getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        }));
    },
    toCash: function(t) {
        var a = t.currentTarget.dataset.id, e = t.currentTarget.dataset.money, i = 1;
        2 == this.data._num && (i = 2), this.setData({
            id: a,
            is_cash: !0,
            content: "小程序端操作",
            cash_price: e,
            cash_status: i
        });
    },
    toDecline: function(t) {
        var a = t.currentTarget.dataset.id;
        t.currentTarget.dataset.money;
        this.setData({
            id: a,
            is_decline: !0,
            content: "",
            cash_status: 3
        });
    },
    toPass: function(t) {
        var a = t.currentTarget.dataset.id;
        this.setData({
            id: a,
            is_pass: !0,
            content: "小程序端操作",
            cash_status: 1
        });
    },
    toRefuse: function(t) {
        var a = t.currentTarget.dataset.id, e = 0;
        2 == this.data._num && (e = 3), this.setData({
            id: a,
            is_refuse: !0,
            cash_status: e,
            content: ""
        });
    },
    input: function(t) {
        this.setData({
            content: t.detail.value
        });
    },
    onLoad: function(t) {
        getApp().page.onLoad(this,t)
        if (this.data.store.is_shenhe == 0) {
          wx.setNavigationBarTitle({
            title: '提现申请'
          })
        }
        this.setData({
            share: t.share,
            mch: t.mch
        }), 0 == t.mch && 1 == t.share ? (getApp().api.setNavigationBarTitle({
            title: "分销商提现申请"
        }), this.setData({
            _num: 2
        })) : 1 == t.mch && 0 == t.share && getApp().api.setNavigationBarTitle({
            title: "入驻商提现申请"
        });
    },
    getList: function(t) {
        var a = this;
        getApp().core.showLoading({
            content: "加载中"
        }), getApp().request({
            url: getApp().api.admin.cash.list,
            data: {
                page: t,
                type: this.data._num,
                status: this.data.status,
                keyword: this.data.keyword
            },
            method: "get",
            success: function (t) {
              getApp().core.hideLoading()
              if ( 0 == t.code) {
                var e = t.data.list, i = !1;
                20 == e.length && 1 == a.data._num && (i = !0), 10 == e.length && 2 == a.data._num && (i = !0),
                  a.setData({
                    list: e,
                    more_list: i,
                    page: 2
                  });
              } else 1 == a.data._num ?[] : getApp().core.showToast({
                title: t.msg,
                icon: 'none'
              });
            },
            fail: function (t) {
              getApp().core.showToast({
                title: t.msg,
                icon: 'none'
              });
            }
        });
    },
    getMore: function(t) {
        var a = this;
        getApp().core.showLoading({
          content: "加载中"
        }), getApp().request({
            url: getApp().api.admin.cash.list,
            data: {
                page: t,
                type: this.data._num,
                status: this.data.status,
                keyword: this.data.keyword
            },
            method: "get",
            success: function () {
              getApp().core.hideLoading()
              if (0 == e.code) {
                var i = a.data.list, s = e.data.list, n = !1;
                20 == s.length && 1 == a.data._num && (n = !0), 10 == s.length && 2 == a.data._num && (n = !0),
                  i = i.concat(s), t++ , a.setData({
                    list: i,
                    page: t,
                    more_list: n
                  });
              } else getApp().core.showToast({
                title: e.data.msg,
                icon: 'none'
              });
            },
            fail: function() {
              getApp().core.showToast({
                title: t.data.msg,
                icon: 'none'
              });
            }
        });
    },
    onReady: function(t) {
        this.setData({
            page_loading: !1
        });
    },
    onShow: function() {
        this.getList(1);
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.more_list && this.getMore(this.data.page);
    },
    onShareAppMessage: function() {}
});